package com.bluemobi.framework.pay.wechat.service;

import java.io.IOException;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.UnrecoverableKeyException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.bluemobi.framework.pay.wechat.common.HttpsRequest;

/**
 * 支付基础service
 *
 * @author zhangyong
 * @version 1.0
 * @Date 2016-4-26 10:28
 */
public class BasePayService {

	protected Log logger = LogFactory.getLog(getClass());

	// API的地址
	private String apiURL;

	// 发请求的HTTPS请求器
	private ServiceRequest serviceRequest;

	public BasePayService(String api) throws UnrecoverableKeyException, IOException, NoSuchAlgorithmException,
			KeyStoreException, KeyManagementException, NoSuchProviderException {
		apiURL = api;
		serviceRequest = (ServiceRequest) new HttpsRequest();
	}

	protected String sendPost(Object xmlObj) throws UnrecoverableKeyException, IOException, NoSuchAlgorithmException,
			KeyStoreException, KeyManagementException, NoSuchProviderException {
		return serviceRequest.sendPost(apiURL, xmlObj);
	}

	protected String sendPost(String apiURL, Object xmlObj) throws UnrecoverableKeyException, IOException,
			NoSuchAlgorithmException, KeyStoreException, KeyManagementException, NoSuchProviderException {
		return serviceRequest.sendPost(apiURL, xmlObj);
	}
}
